<template>
  <div class="user">
    <!-- 顶部导航栏 -->
    <van-cell-group>
      <!-- 用户区域 -->
      <van-cell class="user-info">
        <!-- 头像 -->
        <van-image
          width="50"
          height="50"
          round
          :src="userInfo.portrait || 'https://ss1.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D450%2C600/sign=a587b23df11f3a295a9dddcaac159007/500fd9f9d72a60590cfef2f92934349b023bba62.jpg'"
        ></van-image>
        <!-- 用户信息 -->
        <div class="user-info-content">
          <h3 v-text="userInfo.userName">昵称</h3>
          <span>
            <van-icon name="edit" />
            编辑个人信息
          </span>
        </div>
      </van-cell>
      <van-cell class="account-info">
        <!-- 账户信息 -->
        <van-grid :border="false" class="account-info-grid">
          <van-grid-item>
            <span class="grid-item-value">14.05</span>
            <span>学习时长</span>
          </van-grid-item>
          <van-grid-item>
            <span class="grid-item-value">200</span>
            <span>钱包</span>
          </van-grid-item>
          <van-grid-item>
            <span class="grid-item-value">1</span>
            <span>优惠券</span>
          </van-grid-item>
          <van-grid-item>
            <span class="grid-item-value">213</span>
            <span>学分</span>
          </van-grid-item>
        </van-grid>
      </van-cell>
      <van-cell icon="user-o" title="分销中心" is-link value="收益200块"></van-cell>
      <van-cell icon="setting-o" title="个性设置" is-link></van-cell>
      <van-cell icon="down" title="下载列表" is-link></van-cell>
      <van-cell icon="question-o" title="w帮助与反馈" is-link></van-cell>
      <van-cell icon="info-o" title="关于拉勾教育" is-link value="v2.0.0"></van-cell>
    </van-cell-group>
    <!-- 底部导航' -->
    <layout-footer></layout-footer>
  </div>
</template>

<script>
import { getInfo } from '@/services/user'
import LayoutFooter from '@/components/Layout'

export default {
  name: 'user',
  components: {
    LayoutFooter
  },
  data () {
    return {
      userInfo: {}
    }
  },
  methods: {
    async loadUserInfo () {
      const { data } = await getInfo()
      if (data.state === 1) {
        this.userInfo = data.content
      }
    }
  },
  created () {
    this.loadUserInfo()
  }
}
</script>

<style scoped>
.user-info-content{
  padding-left: 15px;
}
.user-info{
  padding: 30px 20px 0;
  background-color: rgb(248, 150, 3);
}
.user-info-content h3{
  margin: 5px;
  font-size: 18px;
}
.user-info .van-cell__value{
  display: flex;
}
.account-info{
  background-color: rgb(248, 150, 3);
  margin-top: -1px;
}
.account-info .van-cell__value{
  border-radius: 20px;
}
.account-info .grid-item-value{
  font-size: 18px;
  font-weight: bolder;
}
</style>
